﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebDomain.Entities;
using System.Web.Mvc;

namespace CZTopComputers.Models
{
    public class CustomPCViewModel
    {
        public IEnumerable<Product> Products { get; set; }

        public CustomPC CustomPC { get; set; }
        public SelectList Cases { get { return ProductsByType("Case"); } }
        public SelectList Motherboards { get { return ProductsByType("Motherboard"); } }
        public SelectList Processors { get { return ProductsByType("Processor"); } }
        public SelectList Memories { get { return ProductsByType("Memory"); } }
        public SelectList GraphicsCards { get { return ProductsByType("Graphics Card"); } }
        public SelectList HardDrives { get { return ProductsByType("Hard Drive"); } }
        public SelectList PowerSupplies { get { return ProductsByType("Power Supply"); } }
        public SelectList MediaDrives { get { return ProductsByType("Media Drive"); } }
        public SelectList Numbers { get { return new SelectList(new List<int> { 1, 2, 3, 4 }); } }

        private SelectList ProductsByType(string category)
        {
            return new SelectList(this.Products.Where(p => p.Type == category).ToList(), "ID", "Name");
        }
    }
}